<?php

class Orders extends CActiveRecord
{
  const STATUS_PENDING = 0;
  const STATUS_APPROVED = 1;

	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	public function tableName()
	{
		return 'orders';
	}

	public function rules()
	{
		return array(
      array('modified_at','safe'),
			array('name, email, address, phone', 'required'),
      //array('phone', 'numerical', 'integerOnly'=>true),
		);
	}

	public function relations()
	{
		return array(
            'user' => array(self::BELONGS_TO, 'Users', 'user_id'),
            'detail_orders' => array(self::HAS_MANY, 'DetailOrders', 'order_id'),
		);
	}

	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'description' => 'Description',
		);
	}

  public function test()
  {
    return rules();
  }
}